from django.db import models


class TdsdUser(models.Model):
    username = models.CharField(max_length=60, unique=True)
    password = models.CharField(max_length=78)
    telephone = models.CharField(max_length=30, blank=True, null=True)
    create_time = models.DateTimeField(auto_now_add=True)
    update_time = models.DateTimeField(auto_now=True)
    level_id = models.IntegerField()
    dir_id = models.IntegerField(default=0)
    isdelete = models.BooleanField(default=0)
    appkey = models.CharField(max_length=60, unique=True)
    class Meta:
        db_table = 'tdsd_user'


class TdsdApplyResource(models.Model):
    apply_user_id = models.IntegerField()
    resource_id = models.IntegerField()
    resource_user_id = models.IntegerField()
    apply_time = models.DateTimeField()
    status = models.IntegerField(default=0)
    # refuse_reason = models.TextField(null=True)
    token = models.CharField(max_length=64, default=None)
    isdelete = models.BooleanField(default=0)
    isoperated = models.BooleanField(default=0)  # 只有待审核的是0，通过和拒绝都是1

    class Meta:
        db_table = 'tdsd_apply_resource'


class UserApi(models.Model):
    user_id = models.IntegerField()
    create_id = models.IntegerField()
    api = models.CharField(max_length=225, default='')
    user_ip = models.CharField(max_length=225, default='')
    usetime = models.DateTimeField(auto_now=True)
    resouce_status = models.BooleanField(default=0)

    class Meta:
        db_table = 'tdsd_user_api'


class TdsdMessage(models.Model):
    user_id = models.IntegerField()
    # resource_id = models.IntegerField()
    # 用于在被拒绝页面中点击查看原因，可依据此将message表中的原因取出
    apply_resource_tb_id = models.IntegerField()
    title = models.CharField(max_length=100)
    message = models.TextField()
    message_url = models.CharField(max_length=255)
    push_time = models.DateTimeField()
    status = models.IntegerField(default=0)
    sender_id = models.IntegerField()
    isdelete = models.IntegerField(default=0)

    class Meta:
        db_table = 'tdsd_message'



